package site.brood.mall.config.swagger;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * Swagger配置类
 */
@Configuration
public class SwaggerConfig {

    /**
     * 配置swagger的Docket bean
     * @return
     */
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.OAS_30) //指定swagger3.0版本
                .groupName("后端开发组")
                //指定文档摘要配置
                .apiInfo(createApiInfo())
                .enable(true);     //生产环境关闭swagger，影响性能
    }

    /**
     * 文档摘要配置
     * 配置swagger的ApiInfo bean
     * @return
     */
    @Bean
    public ApiInfo createApiInfo(){
        return new ApiInfo("brood server",
                "电商后端服务",
                "0.1",
                "http://localhost:8888",
                new Contact("brood","http://www.brood.site","1725288552@qq.com"),
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList()
        );
    }
}
